
<?PHP
function checkwgateid($wgateid){

			$res = M('user')->where(array('del'=>0,'wgateid'=>$wgateid))->find();
			if(count($res) == 0)
				$result['success'] = 0;
			else {
				if($res['type'] == '1'){
					$info = M('student')->where(array('del'=>0,'id'=>$res['sid']))->find();
				}
				else{
					$info = M('teacher')->where(array('del'=>0,'id'=>$res['sid']))->find();
				}
				if($info['state'] == '1')
					$result['success'] = 2;
				else if($info['state'] == '2') {
					$result['success'] = 1;
				}
				else{
					$result['success'] = 3;
				}
        $result['name'] = $info['name'];
				$result['uid'] = $res['id'];
				$result['type'] = $res['type'];
				return $result;
			}
}
